#include <cstdio>
#include <cctype>


#define MAX_STRING 1002


inline char * get_string (char *s, size_t SIZE = MAX_STRING)
{
	return fgets (s, SIZE, stdin);
}


inline int len_subsequence (const char *s, const char *t)
{
	int r;

	fprintf(stderr, "BEGIN\n\n");
	r = 0;
	while (*s == *t && isalpha (*s) && isalpha (*t))
	{
		fprintf(stderr, "\tr: %d\n\ts: %s\tt: %s\n", r, s, t);
		++r;
		++s;
		++t;
	}
	fprintf(stderr, "\tr: %d\n\ts: %s\tt: %s\nEND\n\n\n", r, s, t);

	return r;
}


inline int len_longest_subsequence (const char *s, const char *t)
{
	int r, l;

	r = 0;
	for (; isalpha (*s); ++s)
	{
		for (const char *u = t; isalpha (*u); ++u)
		{
			l = len_subsequence (s, u);
			if (r < l)
				r = l;
		}
	}

	return r;
}


int main ()
{
	char s[MAX_STRING], t[MAX_STRING];

	while (get_string (s) && get_string (t))
	{
		printf("%d\n", len_longest_subsequence (s, t));
		fprintf(stderr, "\n------------------------\n\n\n\n");
	}

	return 0;
}